﻿@using Newtouch.Infrastructure;
@{

    ViewBag.Title = "编辑排班";
    Layout = "~/Views/Shared/_Form.cshtml";
}

<!DOCTYPE html>

<form id="form1">
    <div style="padding: 20px 35px 0 2px;">
        <table class="form" id="timetable">
            <tr>
                <th class="formTitle"><span class="required">*</span>组织机构：</th>
                <td class="formValue" colspan="3">
                    <select id="OrganizeId" name="OrganizeId" class="form-control required">
                        <option value="">==请选择==</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th class="formTitle"><span class="required">*</span>门诊类型：</th>
                <td class="formValue" colspan="3">
                    <select id="mjzbz" name="mjzbz" class="form-control required" data-EnumType="EnumOutPatientType">
                        <option value="">==请选择==</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th class="formTitle">排班描述 ：</th>
                <td class="formValue" colspan="3">
                    <input type="text" class="form-control" id="pbdesc" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">挂号项目 ：</th>
                <td class="formValue" colspan="3">
                    <input type="hidden" class="form-control" id="ghlx" />
                    <input type="text" class="form-control" id="sfxmmc" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">诊疗项目 ：</th>
                <td class="formValue" colspan="3">
                    <input type="hidden" class="form-control" id="zlxm" />
                    <input type="text" class="form-control" id="zlxmmc" />
                </td>
            </tr>
            <tr>
                <th class="formTitle"><span class="required">*</span>科室 ：</th>
                <td class="formValue" colspan="3">
                    <input type="hidden" class="form-control" id="ks" />
                    <input type="text" class="form-control required" id="ksmz" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">专家医生 ：</th>
                <td class="formValue" colspan="3">
                    <input type="hidden" class="form-control" id="ys" />
                    <input type="text" class="form-control" id="ysxm" />
                    <input type="text" class="form-control" width="1" id="sjd" style="display:none" />
                </td>
            </tr>
            <tr>
                <th class="formTitle" style="padding-left:10px;">开放网络预约 ：</th>
                <td class="formValue" style="padding-left:10px;">
                    <input name='isBook' id="isBook1" type='radio' value='1' />是
                    <input name='isBook' id="isBook2" type='radio' value='0' checked="checked" />否
                </td>
                <th class="formTitle" style="padding-left:10px;">时段类型 ：</th>
                <td class="formValue" colspan="2">
                    <input name='issjd' id="issjd1" type='radio' value='1' onclick="xzsd(true)" />时间区间
                    <input name='issjd' id="issjd2" type='radio' value='0' checked="checked" onclick="xzsd(false)" />上下午
                </td>
                <th class="formTitle" style="padding-left:10px;">默认号源数 ：</th>
                <td class="formValue" style="padding-left:10px;">
                    <input type="text" value="0" class="form-control required" placeholder="默认号源数" id="mrhys" />
                </td>
                <td class="formValue">
                    <div class="ckbox">
                        <input id="zt" type="checkbox" checked="checked"><label for="zt">有效</label>
                    </div>
                </td>
            </tr>
            <tr style="border-bottom: 1px solid #e5e5e5;border-top: 1px solid #e5e5e5;">
                <td class="formValue" id="timetd">
                    &nbsp;&nbsp;&nbsp;&nbsp;时间区间
                </td>
                <td class="formValue">
                    周一
                </td>
                <td class="formValue">
                    周二
                </td>
                <td class="formValue">
                    周三
                </td>
                <td class="formValue">
                    周四
                </td>
                <td class="formValue">
                    周五
                </td>
                <td class="formValue">
                    周六
                </td>
                <td class="formValue">
                    周日
                </td>
            </tr>
           
</form>

<script>
    var ghpbId = $.request("ghpbId");
    var OrganizeId = $.request("OrganizeId");
    var type = $.request("type");
    var inttime = 1;
    var sjdxz = "";
    var datalength = 0;
    $(function () {
        getstrhtml();
        initControl();
        getDateInfo(true);
        getArrangeInfo();
    })
    $('#mrhys').blur(function () {
        if ($('#issjd1').prop('checked')) {
            jzsjd();
        }
        else {
            xzsd(false);
        }
    });
    function getstrhtml() {
        for (var j = 1; j < 3; j++) {
            var strhtml = '<tr id="strtr' + j + '" ><td class="formValue">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;上午</td>';
            if (j==2) {
                strhtml = '<tr id="strtr' + j + '" ><td class="formValue">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;下午</td>';
            }
            if (j == 2) {
                for (var i = 1; i < 8; i++) {
                    strhtml += '<td class="formValue"><input  style="border-top:0px;border-left:0px;border-right:0px;" type = "text"class="form-control required" placeholder = "号源" value="' + $('#mrhys').val() + '" id = "hy' + j+ i + '" /></td >';
                }
            } else {
                for (var i = 1; i < 8; i++) {
                    strhtml += '<td class="formValue"><input  style="border-top:0px;border-left:0px;border-right:0px;" type = "text"class="form-control required" placeholdsser = "号源" value="' + $('#mrhys').val() + '" id = "hy' + i + '" /></td >';
                }
            }
            strhtml += '</tr>';
            $('#timetable').append(strhtml);
        }
    }
    function jzsjd() {
        $('#timetd').html('&nbsp;&nbsp;&nbsp;&nbsp;时间区间');
        $('#strtr1').remove();
        $('#strtr2').remove();
        $('#strtr3').remove();
        $.ajax({
            url: "/OutPatientManage/OutBook/getDateInfosjd",
            dataType: "json",
            async: false,
            success: function (data) {
                datalength = data.length;
                for (var i = 1; i <= inttime; i++) {
                    $('#strtr' + i).remove();
                }
                $('#sjd').val('');
                inttime = 1;
                for (var i = 0; i < data.length; i++) {
                    var strhtml = '<tr id="strtr' + inttime + '" ><td class="formValue"><input name="timestr" type = "text" style="border-top:0px;border-left:0px;border-right:0px;border-bottom:0px;"  readonly="readonly"  class="form-control required" placeholder = "时间区间" value="' + data[i] + '" id = "sjd' + inttime + '" /></td>';
                    for (var j = 1; j < 8; j++) {
                        strhtml += '<td class="formValue"><input name="hy' + inttime + '"  style="border-top:0px;border-left:0px;border-right:0px;" type = "text"  class="form-control required" placeholder = "号源" value="' + $('#mrhys').val() + '" id = "hy' + j + '" /></td >';
                    }
                    strhtml += '</tr>';
                    $('#timetable').append(strhtml);
                    inttime += 1;
                }
            }
        });
    }
    function xzsd(isxz) {
        if (isxz == true) {
            getDateInfo(false);
        } else {
            $('#timetd').html('&nbsp;&nbsp;&nbsp;&nbsp;上下午');
            for (var i = 1; i <= inttime; i++) {
                $('#strtr'+i).remove();
            }
            $('#sjd').val('');
            inttime = 1;
            $('#strtr1').remove();
            $('#strtr2').remove();
            $('#strtr3').remove();
            getstrhtml();
            getdate();
        }
    }
    function btn_addtime(intstrhtml) {
        for (var o = 1; o <= intstrhtml; o++) {
            inttime += 1;
            var strhtml = '<tr id="strtr' + inttime + '"><td class="formValue" ></td ><td class="formValue"><select class="form-control" id="sjxz' + inttime + '" ></select></td>';
            for (var i = 1; i < 8; i++) {
                strhtml += '<td class="formValue"><input type = "text" style = "height:16px;width:35px;" class="form-control required" placeholder = "号源" value="' + $('#mrhys').val() + '" id = "hy' + i + '" /></td >';
            }
            strhtml += '</tr>';
            $('#timetable').append(strhtml);
            if (sjdxz != null && sjdxz != "") {
                for (var u = 1; u <= inttime; u++) {
                    $("#sjxz" + u).html('');
                }
                for (var j = 1; j <= inttime; j++) {
                    for (var i = 0; i < sjdxz.split(',').length; i++) {
                            $("#sjxz" + j).append("<option value='" + i + "'>" + sjdxz.split(',')[i] + "</option>");
                    }
                }
            }
        }
    }
    function btn_clertime(inttimetr) {
        if (inttimetr != 1) {
            $('#strtr' + inttimetr).remove();
        }
    }
    function initControl() {
        //组织机构下拉框
        $("#OrganizeId").bindSelect({
            url: "/SystemManage/Organize/GetChildTreeSelectJson",
        });
        //组织机构是否可选
        if (type == "update") {//更新不可改
            $('#OrganizeId').attr("disabled", true);
        } else {//新增可改
            $('#OrganizeId').attr("disabled", false);
        }


    }

    //获取排班信息
    function getArrangeInfo(){
        if (!!ghpbId) {
            $.ajax({
                url: "/OutPatientManage/OutBook/getArrangeInfo?ghpbId=" + ghpbId,
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                }
            });
        }
    }
    function getdate() {
        if (!!ghpbId) {
            $.ajax({
                url: "/OutPatientManage/OutBook/getDateInfo?ghpbId=" + ghpbId,
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                    if (data && data.isBook == "1") {
                        $('#isBook1').prop('checked', true);
                    } else { $('#isBook2').prop('checked', true); }
                }
            });
        }
    }
    //获取每天开放号源数
    function getDateInfo(pdsj) {
        if (!!ghpbId) {
            $.ajax({
                url: "/OutPatientManage/OutBook/getDateInfosjdcount?ghpbId=" + ghpbId,
                dataType: "json",
                async: false,
                success: function (data) {
                    if (data != null && data != "") {
                        jzsjd();
                        $('#issjd1').prop('checked', true);
                        var aa = document.getElementsByName('timestr');
                        for (var i = 0; i < aa.length; i++) {
                            $.ajax({
                                url: "/OutPatientManage/OutBook/getDateTimeInfo?ghpbId=" + ghpbId + "&timeslot="+aa[i].value,
                                dataType: "json",
                                async: false,
                                success: function (data1) {
                                    if (data1 != null && data1 != "") {
                                        if (data1[0].isBook == "1") {
                                            $('#isBook1').prop('checked', true);
                                        } else { $('#isBook2').prop('checked', true);}
                                        document.getElementsByName("hy" + (i + 1) + "")[0].value = data1[0].hy1;
                                        document.getElementsByName("hy" + (i + 1) + "")[1].value = data1[0].hy2;
                                        document.getElementsByName("hy" + (i + 1) + "")[2].value = data1[0].hy3;
                                        document.getElementsByName("hy" + (i + 1) + "")[3].value = data1[0].hy4;
                                        document.getElementsByName("hy" + (i + 1) + "")[4].value = data1[0].hy5;
                                        document.getElementsByName("hy" + (i + 1) + "")[5].value = data1[0].hy6;
                                        document.getElementsByName("hy" + (i + 1) + "")[6].value = data1[0].hy7;
                                    }
                                }
                            });
                        }
                    } else {
                        if (pdsj) {
                            $('#issjd2').prop('checked', true);
                            $.ajax({
                                url: "/OutPatientManage/OutBook/getDateInfo?ghpbId=" + ghpbId,
                                dataType: "json",
                                async: false,
                                success: function (data) {
                                    $("#form1").formSerialize(data);
                                    if (data && data.isBook == "1") {
                                        $('#isBook1').prop('checked', true);
                                    } else { $('#isBook2').prop('checked', true); }
                                }
                            });
                        } else {
                            jzsjd();
                        }
                        
                    }
                }
            });
        }
    }
    //获取每天开放号源数
    function getDatemoren(pdsj) {
        if (!!ghpbId) {
            $.ajax({
                url: "/OutPatientManage/OutBook/getDateInfosjdcount?ghpbId=" + ghpbId,
                dataType: "json",
                async: false,
                success: function (data) {
                    if (data != null && data != "") {
                        jzsjd();
                        $('#issjd1').prop('checked', true);
                        var aa = document.getElementsByName('timestr');
                        for (var i = 0; i < aa.length; i++) {
                            $.ajax({
                                url: "/OutPatientManage/OutBook/getDateTimeInfo?ghpbId=" + ghpbId + "&timeslot=" + aa[i].value,
                                dataType: "json",
                                async: false,
                                success: function (data1) {
                                    if (data1 != null && data1 != "") {
                                        if (data1[0].isBook == "1") {
                                            $('#isBook1').prop('checked', true);
                                        } else { $('#isBook2').prop('checked', true); }
                                        document.getElementsByName("hy" + (i + 1) + "")[0].value = $('#mrhys').val();
                                        document.getElementsByName("hy" + (i + 1) + "")[1].value = $('#mrhys').val();
                                        document.getElementsByName("hy" + (i + 1) + "")[2].value = $('#mrhys').val();
                                        document.getElementsByName("hy" + (i + 1) + "")[3].value = $('#mrhys').val();
                                        document.getElementsByName("hy" + (i + 1) + "")[4].value = $('#mrhys').val();
                                        document.getElementsByName("hy" + (i + 1) + "")[5].value = $('#mrhys').val();
                                        document.getElementsByName("hy" + (i + 1) + "")[6].value = $('#mrhys').val();
                                    }
                                }
                            });
                        }
                    }
                }
            });
        }
    }
    //确定按钮点击事件
    function AcceptClick(callBack) {
        if (!$('#form1').formValid()) {
            return false;
        }
        var postData = $("#form1").formSerialize();
        postData.zt = postData.zt == true ? "1" : "0";
        if (postData.sfxmmc == "") {
            postData.ghlx = "";
        }
        if (postData.zlxmmc == "") {
            postData.zlxm = "";
        }
        if (postData.ksmz == "") {
            postData.ks = "";
        }
        if (postData.mjzbz == '3' && (postData.ys == '' || postData.ysxm == '')) {
            $.modalAlert("专家门诊必须选择专家医生", 'warning');
            return false;
        }
        if (postData.ysxm=="") {
            postData.ys = "";
        }
        if (postData.ys=="") {
            postData.ysxm = ""
        }
        if ($('#isBook1').prop('checked')) {
            postData.isBook = '1';
        } else { postData.isBook = '0';}
        if ($('#issjd1').prop('checked')) {
            if (ghpbId != null && ghpbId != "" && ghpbId != "0") {
                $.ajax({
                    url: "/OutPatientManage/OutBook/DeleteArrange?ghpbId=" + ghpbId,
                    dataType: "json",
                    async: false,
                    success: function () {
                    }
                });
            }
            else {
                for (var i = 1; i <= 1; i++) {
                    var aa = document.getElementsByName('hy' + i);
                    postData.hy1 = aa[0].value;
                    postData.hy2 = aa[1].value;
                    postData.hy3 = aa[2].value;
                    postData.hy4 = aa[3].value;
                    postData.hy5 = aa[4].value;
                    postData.hy6 = aa[5].value;
                    postData.hy7 = aa[6].value;
                    postData.sjd = $('#sjd' + i).val();
                    $.ajax({
                        url: "/OutPatientManage/OutBook/SubmitArrangeADD?ghpbId=" + ghpbId,
                        dataType: "json",
                        data: postData,
                        async: false,
                        success: function (ghpbIdNew) {
                            ghpbId = ghpbIdNew.message;
                        }
                    });
                    //$.submitForm({
                    //    url: "/OutPatientManage/OutBook/SubmitArrangeADD?ghpbId=" + ghpbId,
                    //    param: postData,
                    //    async: false,
                    //    success: function (ghpbIdNew) {
                    //        ghpbId = ghpbIdNew;
                    //    }
                    //})
                    $.ajax({
                        url: "/OutPatientManage/OutBook/DeleteArrange?ghpbId=" + ghpbId,
                        dataType: "json",
                        async: false,
                        success: function () {
                        }
                    });
                }
                
            }
            if (ghpbId != null && ghpbId != "" && ghpbId != "0") {
                for (var i = 1; i <= inttime; i++) {
                    var aa = document.getElementsByName('hy' + i);
                    postData.hy1 = aa[0].value;
                    postData.hy2 = aa[1].value;
                    postData.hy3 = aa[2].value;
                    postData.hy4 = aa[3].value;
                    postData.hy5 = aa[4].value;
                    postData.hy6 = aa[5].value;
                    postData.hy7 = aa[6].value;
                    postData.sjd = $('#sjd' + i).val();
                    $.ajax({
                        url: "/OutPatientManage/OutBook/SubmitArrange?ghpbId=" + ghpbId,
                        dataType: "json",
                        data: postData,
                        async: false,
                        success: function () {
                        }
                    });
                    if (i == inttime - 1) {
                        callBack();
                        $.modalClose();
                    }
                }
            }
        } else {
            if (ghpbId != null && ghpbId != "") {
                $.ajax({
                    url: "/OutPatientManage/OutBook/DeleteArrange?ghpbId=" + ghpbId,
                    dataType: "json",
                    async: false,
                    success: function () {
                    }
                });
            }
            $.submitForm({
                url: "/OutPatientManage/OutBook/SubmitArrange?ghpbId=" + ghpbId,
                param: postData,
                success: function () {
                    callBack();
                    $.modalClose();
                }
            })
        }
    }


    //挂号项目
    $('#sfxmmc').newtouchFloatingSelector({
        width: 600,
        height: 220,
        caption: "收费项目",
        clickautotrigger: true,
        url: '/SystemManage/BaseData/SelectSfxmYp',
        ajaxparameters: function () {
            return "keyword=" + $.trim($('#sfxmmc').val()) + "&mzzybz=1&dllb=2&sfdllx=OutpatientReg";
        },
        itemdbclickhandler: function ($thistr) {
            $('#sfxmmc').attr('data-ghlx', $thistr.attr('data-sfxmCode'))
                .attr('data-sfxmmc', $thistr.attr('data-sfxmmc'))
                .val($thistr.attr('data-sfxmmc'));
            $('#ghlx').attr('data-ghlx', $thistr.attr('data-sfxmCode'))
                .attr('data-sfxmmc', $thistr.attr('data-sfxmmc'))
                .val($thistr.attr('data-sfxmCode'));
        },
        colModel: [{ label: '编码', name: 'sfxmCode', widthratio: 15 },
        { label: '名称', name: 'sfxmmc', widthratio: 25 },
        { label: '拼音', name: 'py', widthratio: 15 },
        { label: '单位', name: 'dw', widthratio: 8 },
        { label: '单价', name: 'dj', widthratio: 10 },
        { label: '收费大类', name: 'sfdlmc', widthratio: 15 },
        ]
    });

    $('#zlxmmc').newtouchFloatingSelector({
        width: 600,
        height: 180,
        caption: "诊疗项目",
        clickautotrigger: true,
            url: '/OutpatientManage/OutBook/GetMzpbZlxmzhList',
        ajaxparameters: function () {
            return "keyword=" + $.trim($('#zlxmmc').val()) + "&zhcode=";
        },
        itemdbclickhandler: function ($thistr) {
            $('#zlxmmc').attr('data-zhcode', $thistr.attr('data-zhcode'))
                .attr('data-zhmc', $thistr.attr('data-zhmc'))
                .val($thistr.attr('data-zhmc'));
            $('#zlxm').attr('data-zhcode', $thistr.attr('data-zhcode'))
                .attr('data-zhmc', $thistr.attr('data-zhmc'))
                .val($thistr.attr('data-zhcode'));
        },
        colModel: [{ label: '编码', name: 'zhcode', widthratio: 15 },
            { label: '名称', name: 'zhmc', widthratio: 55 },
            { label: '金额', name: 'zhje', widthratio: 10 },
            //{ label: '收费大类', name: 'sfdl', widthratio: 15 },
        ]
    });

    //诊疗项目
    //$('#zlxmmc').newtouchFloatingSelector({
    //    width: 600,
    //    height: 180,
    //    caption: "诊疗项目",
    //    clickautotrigger: true,
    //    url: '/SystemManage/BaseData/SelectSfxmYp',
    //    ajaxparameters: function () {
    //        return "keyword=" + $.trim($('#zlxmmc').val()) + "&mzzybz=1&dllb=2&sfdllx=Diagnose";
    //    },
    //    itemdbclickhandler: function ($thistr) {
    //        $('#zlxmmc').attr('data-zlxm', $thistr.attr('data-sfxmCode'))
    //            .attr('data-sfxmmc', $thistr.attr('data-sfxmmc'))
    //            .val($thistr.attr('data-sfxmmc'));
    //        $('#zlxm').attr('data-zlxm', $thistr.attr('data-sfxmCode'))
    //            .attr('data-sfxmmc', $thistr.attr('data-sfxmmc'))
    //            .val($thistr.attr('data-sfxmCode'));
    //    },
    //    colModel: [{ label: '编码', name: 'sfxmCode', widthratio: 15 },
    //    { label: '名称', name: 'sfxmmc', widthratio: 25 },
    //    { label: '拼音', name: 'py', widthratio: 15 },
    //    { label: '单位', name: 'dw', widthratio: 8 },
    //    { label: '单价', name: 'dj', widthratio: 10 },
    //    { label: '收费大类', name: 'sfdlmc', widthratio: 15 },
    //    ]
    //});

    //科室
    $('#ksmz').newtouchFloatingSelector({
        width: 400,
        height: 180,
        caption: "科室",
        clickautotrigger: true,
        /*
        url: '/OutpatientManage/OutpatientRegSchedule/GetSysDepartmentList',
        ajaxmethod: 'POST',
        ajaxreqdata: function () {
            var reqData = {};
            reqData.keyword = $("#ksmz").val();
            return reqData;
        },
        */
        filter: function (keyword) {
            var resultObjArr = new Array();
            $.each(top.window.clients.sysDepartList, function (idx, val) {
                if (keyword == "" || val.Name.indexOf(keyword) >= 0) {
                    if (val.zlks == "1" || val.zlks == undefined || val.zlks == null) {
                        resultObjArr.push(val);
                    }
                }
            });
            return resultObjArr;
        },
        itemdbclickhandler: function ($thistr) {
            $('#ksmz').attr('data-ks', $thistr.attr('data-code'))
                .val($thistr.attr('data-Name'));
            $('#ks').attr('data-ks', $thistr.attr('data-code'))
                .val($thistr.attr('data-code'));
            ////根据科室编号获取医生姓名
            //var ks = $thistr.attr('data-code');

            //$.ajax({
            //    url: "/OutPatientManage/OutBook/getStaffByKs?ks=" + ks,
            //    dataType: "json",
            //    async: false,
            //    success: function (data) {
            //        var staff = "";
            //        for (i = 0; i < data.length; i++) {
            //            staff += data[i] + ",";
            //        }
            //        if (staff.indexOf(",") != -1) {
            //            staff = staff.substring(0, staff.length - 1);
            //        }
            //        $("#ysxm").val(staff);
            //    }
            //});
        },
        colModel: [{ label: '代码', name: 'Code', widthratio: 30 },
        { label: '科室名称', name: 'Name', widthratio: 30 },
        { label: '拼音', name: 'py', widthratio: 30 }
        ]
    });

    ///医生
    $("#ysxm").newtouchFloatingSelector({
        height: 200,
        width: 300,
        clickautotrigger: true,
        filter: function (keyword) {
            //遍历数据源，用keyword来筛选出结果
            var resultObjArr = new Array();

            $.each(top.window.clients.sysStaffDutyList, function (idx, val) {
                if (((val.StaffPY && val.StaffPY.toLowerCase().indexOf(keyword.toLowerCase()) >= 0)
                    || (val.StaffName && val.StaffName.indexOf(keyword.toLowerCase()) >= 0)
                    || keyword.trim() == "")
                    && (val.DutyCode == "Doctor")) {
                    resultObjArr.push(val);
                }
            });
            return resultObjArr;

        },
        caption: "医生",
        colModel: [
            {
                label: '工号', name: 'StaffGh', widthratio: 25
            },
            {
                label: '名称', name: 'StaffName', widthratio: 25
            },
            { label: '拼音', name: 'StaffPY', widthratio: 25 }
        ],
        itemdbclickhandler: function ($thistr) {
            $("#ysxm").attr("data-label", $thistr.find("td:eq(0)").html());
            $("#ysxm").val($thistr.find('td:eq(1)').html());
            $("#ys").val($thistr.find('td:eq(0)').html());
            return;
        }
    });
    //新增时段选择
    function btn_add(inttimede) {
        var sjd = $('#sjd').val();
        $.modalOpen({
            id: "TimeForm",
            title: "编辑排班时间",
            url: "/OutPatientManage/OutBook/TimeForm?type=add&sjd=" + sjd,
            width: "600px",
            height: "600px",
            callBack: function (iframeId) {
                $.currentWindow(iframeId).AcceptClick(function (hysd) {
                    if (hysd != null && hysd != "") {
                        $('#sjd').val(hysd);
                        for (var p = 1; p <= inttime; p++) {
                            btn_clertime(p);
                        }
                        inttime = 1;
                        if (hysd.split(',').length - 1!=0) {
                            btn_addtime(hysd.split(',').length - 1);
                        }
                        for (var u = 1; u <= inttime; u++) {
                            $("#sjxz" + u).html('');
                        }
                        for (var j = 1; j <= inttime; j++) {
                            for (var i = 0; i < hysd.split(',').length; i++) {
                                if (i == (j - 1)) {
                                    $("#sjxz" + j).append("<option value='" + i + "' selected>" + hysd.split(',')[i] + "</option>");
                                }
                                else { 
                                    $("#sjxz" + j).append("<option value='" + i + "'>" + hysd.split(',')[i] + "</option>");
                                }
                            }
                        }
                        sjdxz = hysd;
                    }
                });
            }
        });
    }
    function btn_remove(i) {
        $('#sjd' + i).val('');
    }
</script>
